/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/16
\**********************/
#include "LuaMenuElement.h"

#define CObjPtr ((CMenuElementUI*)m_cobj)

namespace DuiLib {

int LuaMenuElement::EstimateSize(LuaState *L)
{
    LuaStack args(L);
    SIZE szAvailable = LuaHelperNS::GetSize(args[2]);
    SIZE sz = CObjPtr->EstimateSize(szAvailable);
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

int LuaMenuElement::GetMenuWnd(LuaState *L)
{
    CMenuWnd* wnd = CObjPtr->GetMenuWnd();
    LuaHelperNS::PushCObj(L, wnd);
    return 1;
}

void LuaMenuElement::CreateMenuWnd()
{
    CObjPtr->CreateMenuWnd();
}

void LuaMenuElement::SetLineType()
{
    CObjPtr->SetLineType();
}

void LuaMenuElement::SetLineColor(DWORD color)
{
    CObjPtr->SetLineColor(color);
}

DWORD LuaMenuElement::GetLineColor()
{
    return CObjPtr->GetLineColor();
}

int LuaMenuElement::GetLinePadding(LuaState *L)
{
    RECT rc = CObjPtr->GetLinePadding();
    LuaHelperNS::PushRect(L, rc);
    return 1;
}

int LuaMenuElement::SetLinePadding(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    CObjPtr->SetLinePadding(rc);
    return 0;
}

int LuaMenuElement::SetIcon(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetIcon(str.c_str());
    return 0;
}

void LuaMenuElement::SetIconSize(LONG cx, LONG cy)
{
    CObjPtr->SetIconSize(cx, cy);
}
    
void LuaMenuElement::SetChecked(bool bCheck)
{
    CObjPtr->SetChecked(bCheck);
}

bool LuaMenuElement::GetChecked()
{
    return CObjPtr->GetChecked();
}

void LuaMenuElement::SetCheckItem(bool bCheckItem)
{
    CObjPtr->SetCheckItem(bCheckItem);
}

bool LuaMenuElement::GetCheckItem()
{
    return CObjPtr->GetCheckItem();
}

void LuaMenuElement::SetShowExplandIcon(bool bShow)
{
    CObjPtr->SetShowExplandIcon(bShow);
}

SDLUA_BEGIN_REGISTER(LuaMenuElement, MenuElement, ListContainerElement)
    SDLUA_REGISTER_FUN_LUA(LuaMenuElement, EstimateSize, EstimateSize)

    SDLUA_REGISTER_FUN_LUA(LuaMenuElement, GetMenuWnd, GetMenuWnd)
    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, CreateMenuWnd, CreateMenuWnd)

    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, SetLineType, SetLineType)
    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, SetLineColor, SetLineColor)
    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, GetLineColor, GetLineColor)
    SDLUA_REGISTER_FUN_LUA(LuaMenuElement, GetLinePadding, GetLinePadding)
    SDLUA_REGISTER_FUN_LUA(LuaMenuElement, SetLinePadding, SetLinePadding)
    SDLUA_REGISTER_FUN_LUA(LuaMenuElement, SetIcon, SetIcon)
    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, SetIconSize, SetIconSize)

    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, SetChecked, SetChecked)
    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, GetChecked, GetChecked)
    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, SetCheckItem, SetCheckItem)
    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, GetCheckItem, GetCheckItem)
    
    SDLUA_REGISTER_FUN_CPP(LuaMenuElement, SetShowExplandIcon, SetShowExplandIcon)

SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaMenuElement, MenuElement)
SDLUA_END_UNREGISTER(MenuElement)

}

#undef CObjPtr